<?php
/*
	收入明细
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$return=array();
if($_RQ['op']=='list'){
	$params=array();
	$params['uniacid']=$_SESSION['uniacid'];
	$params['status']=1;
	$params['pay_type']=array('wechat','alipay','yinlian');
	if($_RQ['mid']){
		$params['mid']=intval($_RQ['mid']);
		$return['params']['mid']=$_RQ['mid'];
	}
	//创建时间
	if($_RQ['createtime']){
		$time_range=cfc('tools')->base64_decode($_RQ['createtime'],$_SESSION['base_key_str']);
		$time_range=json_decode($time_range,true);
		$return['params']['createtime']=$time_range;
		$params['createtime between']=array($time_range['tstart'],$time_range['tend']);
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$fields=array('id','uniacid','mid','pay_type','fee','title','transaction_id','createtime');
	$list=pdo_getslice('core_paylog',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			$item['member']=model('core/core')->member_show($item['mid']);
			
		}
	}
	
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','tips'=>'收入主要包括会员充值，会员使用非账户余额支付订单等直接打款到商户账户的金额','edit'=>false,'del_one'=>false,'delall'=>false,'list'=>array(
			array('name'=>'member','title'=>'用户信息','type'=>'member'),
			array('name'=>'pay_type','title'=>'支付方式','type'=>'radio','options'=>'pay_types'),
			array('name'=>'fee','title'=>'支付金额','type'=>'string'),
			array('name'=>'createtime','title'=>'支付时间','type'=>'time'),
			array('name'=>'transaction_id','title'=>'第三方支付单号','type'=>'string'),
			array('name'=>'title','title'=>'备注','type'=>'string'),
		)),
		'search'=>array(
			array('name'=>'mid','width'=>30,'title'=>'会员id','type'=>'choose','action'=>'core/member.get_member/'),
			array('name'=>'createtime','width'=>30,'title'=>'支付时间','type'=>'time_range'),
		)
	);
	$return['htmls']=$htmls;
	$return['pay_types']=get_pay_types();
	exi($return);
}
